#pragma semicolon 1
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <colors>
#include <cstrike>
#include <PowerupsX>

#define PREFIX "{olive}PowerupsX {default}>{green} "

new AbilityJump;

new g_iBeamSprite;
new g_iHaloSprite;

public Plugin:myinfo= 
{
	name="PowerupsXL Long-Jump",
	author="Skydive",
	description="Powerups X Long-Jump Ability",
	version="1.0",
	url=""
};

public OnMapStart()
{
	g_iBeamSprite = PrecacheModel("materials/sprites/laser.vmt");
	g_iHaloSprite = PrecacheModel("materials/sprites/halo01.vmt");
}

public OnPluginStart()
{
	NativeIncStart();
	
	AbilityJump = PX_RegisterAbility("AbilityLongJump");
	PX_SetAbilityName(AbilityJump,"Longjump");
	PX_SetAbilityDescription(AbilityJump,"Upon jumping you get a boost forwards! Jump Increase: (Level/8) Max. 12: Hidden.");
	PX_AbilityUseColor(AbilityJump,true);
	PX_SetAbilityColor(AbilityJump,0,255,0,255);
	PX_SetAbilityMaxLevel(AbilityJump,20);
	
	
	HookEvent("player_jump",Event_PlayerJump);
}

public Action:Event_PlayerJump(Handle:event, const String:name[],bool:dontBroadcast)
{
	new userid = GetClientOfUserId(GetEventInt(event,"userid"));
	if(PX_GetAbility(userid) == AbilityJump)	
	{	
		new Level = PX_GetLevel(userid, PX_GetAbility(userid));
		new fJump = 1*Level/8;
		decl Float:jvector[3];
		GetEntPropVector(userid, Prop_Data, "m_vecVelocity", jvector);
		jvector[0] *= 1+fJump;
		jvector[1] *= 1+fJump;
		jvector[2] = 0.0;
		SetEntPropVector(userid,Prop_Data,"m_vecBaseVelocity", jvector);
		if(Level < 12)
		{
			new color[4]={ 188,220,150,200 };
			decl Float:location[3];
			GetClientAbsOrigin(userid, location);
			TE_SetupBeamRingPoint(location, 10.0, 500.0, g_iBeamSprite, g_iHaloSprite, 0, 10, 0.6, 10.0, 0.5, color, 10, 0);
			TE_SendToAll();
		}
	}
}